using UnityEngine;
using System.Collections;

public class sweeperScript : MonoBehaviour {
	public float life = 0.0f;
	public float min = 0.0f, max = 100.0f;
	public int upDown = -1;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		life += Time.deltaTime;
		if(life >= 10.0f){
			GameObject.Destroy(transform.gameObject);
		}
		if(transform.position.z <= min){
			upDown = 1;
		}
		if(transform.position.z >= max){
			upDown = -1;
		}
		transform.Translate(new Vector3(-1,0,1*upDown)*50*Time.deltaTime);
			
	
	}
	void OnTriggerEnter(Collider other){
		PlayerScript p = other.GetComponent<PlayerScript>();
		if(p != null){
			GameObject.Destroy(transform.gameObject);
		}
	}
	public void setMinMax(float mi, float ma){
		min = mi;
		max = ma;
	}
	public void setUpDown(int i){
		upDown = i;
	}
	[RPC]
	void DestroySweeper(){
		GameObject.Destroy(transform.gameObject);
	}
}
